package com.qf.utils;

import cn.hutool.core.date.DateUtil;
import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;

import java.util.Date;

public class TokenUtils {
    public static String create(String sid,String pass){
        return JWT.create()
                .withAudience(sid,pass)
                .withExpiresAt(DateUtil.offsetMinute(new Date(),10))
                .sign(Algorithm.HMAC256(pass));
    }
    public static String getStudentId(String token){
        return JWT.decode(token).getAudience().get(0);
    }
}
